<template>
    <el-card class="box-card">
        <el-form :model="customerForm" ref="customerForm" :rules="rules">
            <el-form-item label="名称" prop="name">
                <el-input v-model="customerForm.name"></el-input>
            </el-form-item>
            <el-form-item label="工号" prop="code">
                <el-input v-model="customerForm.code"></el-input>
            </el-form-item>
            <el-form-item label="电话号码" prop="phone">
                <el-input v-model="customerForm.phone"></el-input>
            </el-form-item>
            <el-form-item label="所在城市名" prop="city_code">
                <el-input v-model="customerForm.city_code"></el-input>
            </el-form-item>
        </el-form>
        <el-col :span="24" class="toolPage">
            <el-button type="primary" @click="submitForm('customerForm')">更新客服经理</el-button>
            <el-button type="danger">删除客服经理</el-button>
            <el-button type="primary" @click="returnCustomerList">返回</el-button>
        </el-col>
    </el-card>
</template>
<script>
    export default {
        data() {
            return {
                customerForm: {
                    name: '',
                    code: '',
                    phone: '',
                    city_code: ''
                },
                rules: {
                    name: [
                        { required: true, message: '请输入姓名', trigger: 'change blur' }
                    ],
                    code: [
                        { required: true, message: '请输入工号', trigger: 'change blur' }
                    ],
                    phone: [
                        { required: true, message: '请输入电话号码', trigger: 'change blur' }
                    ],
                    city_code: [
                        { required: true, message: '请输入所在城市名', trigger: 'change blur' }
                    ]
                }
            }
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            returnCustomerList() {
                this.$router.push(`/customer_managers`);
            }
        }
    }

</script>